<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="utf-8">
        <title>
            小栀科技返利贷后台管理系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/css/x-admin.css" media="all">
    </head>
    <body>
        <div class="x-body">
            <blockquote class="layui-elem-quote">
            </blockquote>
            <div id="main" style="width: 100%;height:400px;"></div>
            <blockquote class="layui-elem-quote">
            </blockquote>
        </div>
        <script src="/js/jquery.min.js" charset="utf-8"></script>
        <script src="/js/echarts.common.min.js" charset="utf-8"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                loadUserCount();
            });

        var myChart = echarts.init(document.getElementById('main'));

        function showPic(data) {
            var userNum = [];
            var userDate = [];
            for(var i=0; i<data.length;i++) {
                userNum[i] = data[i].num;
                userDate[i] = data[i].date;
            }

            var option = {
                title:{
                    text:'注册用户 数据统计'
                },
                tooltip: {},
                legend: {
                    data:['注册量']
                },
                xAxis: {
                    data: userDate
                },
                yAxis: {},
                series: [{
                    name: '注册量',
                    type: 'bar',
                    data: userNum
                }]
            };

            myChart.setOption(option);
        }


        function loadUserCount() {
            $.ajax({
                type : "get",
                dataType : "json",
                url : '/getUserLast7DayCount',
                data : {
                },
                success : function(dataResult) {
                    if (!dataResult.success) {
                        layer.alert(dataResult.message, {icon: 2});
                        return false;
                    }

                    if (dataResult.data.length <= 0) {
                        alert("最近七天没有注册数据");
                    }

                    showPic(dataResult.data);

                },
                error : function(XMLHttpResponse) {
                }
            });
        }
    </script>
    <script>

        </script>
    </body>
</html>